from .puzzle8_solver import Puzzle8Solver,BFSPuzzle8Solver,DFSPuzzle8Solver,AstarPuzzle8Solver
from enum import Enum
class SolverMethod(Enum):
    BFSMethod = 1
    DFSMethod = 2
    AStarMethod = 3

class Puzzle8SolverFactory(object):
    #_instance = None

    @classmethod
    def instance(cls):
        if not hasattr(Puzzle8SolverFactory,"_instance"):
            Puzzle8SolverFactory._instance = Puzzle8SolverFactory()
        return Puzzle8SolverFactory._instance

    def __init__(self):
        self.solver = None
        self.solver_method =  SolverMethod.BFSMethod

    def set_method(self, solver_method):
        if solver_method == SolverMethod.BFSMethod:
            self.solver = BFSPuzzle8Solver()
        elif solver_method == SolverMethod.DFSMethod:
            self.solver = DFSPuzzle8Solver()
        elif  solver_method == SolverMethod.AStarMethod:
            self.solver = AstarPuzzle8Solver();
        else:
            self.solver = None

    def get_solver(self):
        return self.solver;

